
var rootPath = getRootPath();

$(document).ready(function(){
	var userId = getQueryParamValue("userId");
	var vin = getQueryParamValue("vin");
	$("#userId").val(userId);
	$("#vin").val(vin);
	
   var now = new Date();
   var currYear = now.getFullYear();	
   //选择日期
   $('#lastMaintainDate').mobiscroll().date({
       theme: 'ios',
       lang: 'zh',
       display: 'bottom',
       mode: 'datetimeDate',
       max: new Date(now.getFullYear(), now.getMonth(), now.getDate()),
       dateFormat:'yyyy-mm-dd'

   });

	$('#modalCancel').click(function(){
				window.location.reload();
			});
	
	$('#modalSure').click(function(){
		 
		 var data={
				 tmCarOwnerUserId:"",
				 vin:"",
				 lastMaintainDate:"",
				 lastMaintainMileage:"",
			    }; 

		    	data.tmCarOwnerUserId = $.trim($("#userId").val()); 
		    	data.vin = $.trim($("#vin").val()); 
			    data.lastMaintainDate = $.trim($("#lastMaintainDate").val()); 
			    data.lastMaintainMileage = $.trim($("#lastMaintainMileage").val()); 
			    
			    
				$.ajax({
					type : 'POST',
					url : rootPath+'/wechat/api/potentialUsers/maintainRecord',
					contentType:"application/json",
					data: JSON.stringify(data),
					error:function(XMLHttpRequest, ajaxOptions, thrownError){
						alert("失败");
					},
					success : function(data){
						window.location = rootPath + "/views/hp.html";
					}
				});
		 
	});
});